﻿var urlchunks = document.getElementById("hfURLChunks").value;
var baseurl = document.getElementById("hfBaseURL").value;
var tempsplit = urlchunks.split("|");
var currentpath = "DEFAULT";
if (tempsplit.length > 0) {
    currentpath = tempsplit[0];
}
/////////////////////////////////////////////////////////////////////////////

function pimpdefaultbuttons() {
    jQuery(".standardbutton").hover(function () {
        jQuery(this).addClass("standardbuttonhover");
    }, function () {
        jQuery(this).removeClass("standardbuttonhover");
    });
}

//function pimpdefaultmenu() {
//    jQuery(".menuitem").hover(function () {
//        jQuery(this).addClass("menuitemhover");
//    }, function () {
//        jQuery(this).removeClass("menuitemhover");
//    });
//}

function pimpdefaultradio() {
    jQuery(".customradioholder").hover(function () {
        jQuery(this).addClass("customradioholderhover");
    }, function () {
        jQuery(this).removeClass("customradioholderhover");
    });

}

function pimpdefaultmobilemenu() {
    jQuery("#menu a").click(function (e) {
        // navigate

        //jQuery('#menu').collapse("hide");
        //document.getElementById("contentholder").style.display = "";
    });

    jQuery("#buttonMenuManipulator").click(function (e) {
        if (jQuery("#menu").outerWidth() > 0) {
            document.getElementById("contentholder").style.display = "";
            document.getElementById("mobileviewholder").style.background = "none";
        }
        else {
            document.getElementById("contentholder").style.display = "none";
            document.getElementById("mobileviewholder").style.backgroundColor = "#68217A";
        }
    });
}

function loadjscssfile(filename, filetype) {
    if (filetype == "css") { //if filename is an external CSS file
        var fileref = document.createElement("link")
        fileref.setAttribute("rel", "stylesheet")
        fileref.setAttribute("type", "text/css")
        fileref.setAttribute("href", filename)
    }
    else if (filetype == "js") { //if filename is a external JavaScript file
        var fileref = document.createElement("script")
        fileref.setAttribute("type", "text/javascript")
        fileref.setAttribute("src", filename)
    }
    if (typeof fileref != "undefined")
        document.getElementsByTagName("head")[0].appendChild(fileref)
}

jQuery(".menuitem").hover(function () {
    jQuery(this).addClass("menuitemhover");
}, function () {
    jQuery(this).removeClass("menuitemhover");
});

jQuery(".menuitem").click(function (e) {

    var pageName = jQuery(this).find("span").text();
    pageName = pageName.toUpperCase();
    var tourl = "./";

    if ((pageName == "MY ACCOUNT") && (pageName != GENERAL_PAGE_NAME)) {
        tourl = tourl + "myaccount.aspx";
        document.location = tourl;
    }
    if ((pageName == "APPROVAL OF REGISTRATION") && (pageName != GENERAL_PAGE_NAME)) {
        tourl = tourl + "approvalofreg.aspx";
        document.location = tourl;
    }
    if ((pageName == "USER") && (pageName != GENERAL_PAGE_NAME)) {
        tourl = tourl + "usermngt.aspx";
        document.location = tourl;
    }
    if ((pageName == "COMPANY") && (pageName != GENERAL_PAGE_NAME)) {
        tourl = tourl + "companymngt.aspx";
        document.location = tourl;
    }
    if ((pageName == "CATEGORY") && (pageName != GENERAL_PAGE_NAME)) {
        tourl = tourl + "categorymngt.aspx";
        document.location = tourl;
    }
    if ((pageName == "ITEM") && (pageName != GENERAL_PAGE_NAME)) {
        tourl = tourl + "itemmngt.aspx";
        document.location = tourl;
    }
    if ((pageName == "PRICING") && (pageName != GENERAL_PAGE_NAME)) {
        tourl = tourl + "pricingmngt.aspx";
        document.location = tourl;
    }
    if ((pageName == "ADS") && (pageName != GENERAL_PAGE_NAME)) {
        tourl = tourl + "admngt.aspx";
        document.location = tourl;
    }
    if ((pageName == "SETTINGS") && (pageName != GENERAL_PAGE_NAME)) {
        tourl = tourl + "settings.aspx";
        document.location = tourl;
    }
    if ((pageName == "SETTING") && (pageName != GENERAL_PAGE_NAME)) {
        tourl = tourl + "adminsettings.aspx";
        document.location = tourl;
    }
});

function header() {

    var holder = document.getElementById("CommonHeader");

    var dhtml = "";
    dhtml = dhtml + "             <div class=\"navbar navbar-emerson navbar-fixed-top\" role=\"navigation\" style=\"border-radius: 0px;\">";
    dhtml = dhtml + "               <div class=\"container\">";
    dhtml = dhtml + "                 <div class=\"navbar-header\">";
    dhtml = dhtml + "                   <button type=\"button\" class=\"navbar-toggle\" data-toggle=\"collapse\" data-target=\".navbar-collapse\">";
    dhtml = dhtml + "                     <span class=\"sr-only\">Toggle navigation</span>";
    dhtml = dhtml + "                     <span class=\"icon-bar\"></span>";
    dhtml = dhtml + "                     <span class=\"icon-bar\"></span>";
    dhtml = dhtml + "                    <span class=\"icon-bar\"></span>";
    dhtml = dhtml + "                   </button>";
    dhtml = dhtml + "                   <a class=\"navbar-brand\" href=\"/webtemplate.aspx\" style=\"font-weight: bold;\">Web Template</a>";
    //dhtml = dhtml + "                   <a class=\"navbar-brand\" href=\"#\" style=\"font-weight: bold; font-size: 14px;\"><img src=\"resources/images/toolbox.png\" style=\"height: 24px;\" border=\"0\" />Project Monitoring</a>";
    //dhtml = dhtml + "                   <a class=\"navbar-brand\" href=\"#\" style=\"font-weight: bold; font-size: 14px;\"><img src=\"resources/images/emr_logo_white_proposed.png\" style=\"height: 26px;\" border=\"0\" /></a>";
    dhtml = dhtml + "                 </div>";
    dhtml = dhtml + "                 <div class=\"navbar-collapse collapse navbar-right\" style=\"font-size: 12px;\">";
    dhtml = dhtml + "                   <ul class=\"nav navbar-nav\">";
    if ((currentpath.indexOf("DEFAULT") >= 0) || (currentpath.indexOf("DASHBOARD") >= 0))
        dhtml = dhtml + "                     <li class=\"active\"><a  href=\"#\"><span class=\"glyphicon glyphicon-home\"></span>&nbsp;&nbsp;Home</a></li>";
    else
        dhtml = dhtml + "                     <li><a  href=\"#\"><span class=\"glyphicon glyphicon-home\"></span>&nbsp;&nbsp;Home</a></li>";
    if ((currentpath.indexOf("TASKS") >= 0) || (currentpath.indexOf("TASKS") >= 0))
        dhtml = dhtml + "                     <li class=\"active\"><a  href=\"#\"><span class=\"glyphicon glyphicon-user\"></span>&nbsp;&nbsp;User</a></li>";
    else
        dhtml = dhtml + "                     <li><a  href=\"#\"><span class=\"glyphicon glyphicon-user\"></span>&nbsp;&nbsp;User</a></li>";
    dhtml = dhtml + "                     <li class=\"dropdown\">";
    dhtml = dhtml + "                       <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\"><span class=\"glyphicon glyphicon-list-alt\"></span>&nbsp;&nbsp;Reports <b class=\"caret\"></b></a>";
    dhtml = dhtml + "                       <ul class=\"dropdown-menu\"  style=\"font-size: 12px;\">";
    dhtml = dhtml + "                         <li><a href=\"#\">List 1</a></li>";
    dhtml = dhtml + "                         <li><a href=\"#\">List 2</a></li>";
    dhtml = dhtml + "                         <li><a href=\"#\">List 3</a></li>";
    //dhtml = dhtml + "                         <li class=\"divider\"></li>";
    //dhtml = dhtml + "                         <li class=\"dropdown-header\">Nav header</li>";
    //dhtml = dhtml + "                         <li><a href=\"#\">Separated link</a></li>";
    //dhtml = dhtml + "                         <li><a href=\"#\">One more separated link</a></li>";
    dhtml = dhtml + "                       </ul>";
    dhtml = dhtml + "                     </li>";
    dhtml = dhtml + "                   </ul>";
    dhtml = dhtml + "                 </div>";
    dhtml = dhtml + "               </div>";
    dhtml = dhtml + "             </div>";

    holder.innerHTML = dhtml;
}

function Footer() {
    var holder = document.getElementById("footer");
    var dhtml = "";

    dhtml = dhtml + " <div class=\"footer\">";
    dhtml = dhtml + " <div class=\"container\" >";
    dhtml = dhtml + "    <div style=\"color:#808080; margin-top:5px; margin-bottom:5px;\" class=\"visible-lg visible-md\">";
    dhtml = dhtml + "       <div class=\"row\">";
    dhtml = dhtml + "           <div style=\"display:inline-table; float:left; padding-right:30px;\">";
    dhtml = dhtml + "               <img src=\"resources/images/logo.png\" />";
    dhtml = dhtml + "           </div>";
    dhtml = dhtml + "           <div style=\"display:inline-table; float:right; padding-right:30px; text-align:right\">";
    dhtml = dhtml + "               <ul style=\"list-style-type:none; \">";
    dhtml = dhtml + "                   <li><small><a href=\"#\">Privacy Policy</a> &nbsp;&nbsp;&nbsp;&nbsp; <a href=\"#\">Terms of Use</a></small></li>";
    dhtml = dhtml + "                   <li><small></small></li>";
    dhtml = dhtml + "                   <li><small>©2014 Emerson Electric Co. All rights reserved.</small></li>";
    dhtml = dhtml + "                   <li><small>CONSIDER IT SOLVED.</small></li>";
    dhtml = dhtml + "               </ul>";
    dhtml = dhtml + "           </div>";
    dhtml = dhtml + "       </div>";
    dhtml = dhtml + "    </div>";
    dhtml = dhtml + " </div>";
    dhtml = dhtml + " </div>";

    holder.innerHTML = dhtml;
}

function FooterMobile() {
    var holder = document.getElementById("footerMobile");
    var dhtml = "";

    dhtml = dhtml + " <div class=\"container\" style=\"background-color: #f5f5f5;\">";
    dhtml = dhtml + " <div style=\"color:#808080; margin-top:5px; margin-bottom:5px; font-size:9px\" class=\"visible-xs visible-sm\">";
    dhtml = dhtml + "   <div class=\"row\">";
    //dhtml = dhtml + "       <div class=\"col-sm-12\">";
    //dhtml = dhtml + "           <img class=\"img-responsive\" src=\"images/logo.png\" />";
    //dhtml = dhtml + "       </div>";
    //dhtml = dhtml + "       <div>&nbsp;</div>";
    dhtml = dhtml + "       <div class=\"col-sm-12\">";
    dhtml = dhtml + "           <div><a href=\"#\">Privacy Policy</a> &nbsp;&nbsp;&nbsp;&nbsp; <a href=\"#\">Terms of Use</a></div>";
    //dhtml = dhtml + "           <div>&nbsp;</div>";
    dhtml = dhtml + "           <div>©2014 Emerson Electric Co. All rights reserved.</div>";
    dhtml = dhtml + "           <div>CONSIDER IT SOLVED.</div>";
    dhtml = dhtml + "       </div>";
    dhtml = dhtml + "   </div>";
    dhtml = dhtml + " </div>";
    dhtml = dhtml + " </div>";

    holder.innerHTML = dhtml;
}